﻿SELECT *
FROM [SERVER12].[ANHCP].[DBO].[DOANH_SO_BAO_LANH_HTC]

SELECT CUST_ID, B.CUS_NAME, SUM(AMOUNT_QD),BRANCH_NAME_SME, B.BRANCH_ID, ZONE_ID_SME, FUND_PROGRAM, B.DAO, B.DAO_NAME 
FROM [SERVER12].[ANHCP].[DBO].[DOANH_SO_BAO_LANH_HTC] A, TBL_CUSTOMER B
WHERE A.CUST_ID = B.CIF
GROUP BY CUST_ID, B.CUS_NAME,BRANCH_NAME_SME,  B.BRANCH_ID, ZONE_ID_SME, FUND_PROGRAM, B.DAO_NAME, B.DAO
 ORDER BY CUST_ID
 
  INSERT TBL_HR_GROUP_COUNT
  SELECT DAO, '6. GROUP TRADE', COUNT(CIF), 0 , 0, 'TRADE' FROM TBL_CM_TRADE WHERE DAO IS NOT NULL
  GROUP BY DAO

SELECT * FROM TBL_TTQT_DAILY


SELECT CIF, CUSTOMER_NAME, DAO, BRANCH_CODE, BRANCH_NAME_SME, ZONE_ID_SME,  PRODUCT_NAME, SUM(TRANSACTION) AS BAL_QD FROM TBL_TTQT_DAILY

---	KHÁCH HÀNG HẾT HẠN HỢP ĐỒNG BẢO LÃNH, LC, HẠN MỨC



  
  
